#pragma config(Hubs,  S1, HTMotor,  HTMotor,  none,     none)
#pragma config(Sensor, S1,     ,               sensorI2CMuxController)
#pragma config(Motor,  mtr_S1_C1_1,     frontRight,    tmotorTetrix, PIDControl, reversed, encoder)
#pragma config(Motor,  mtr_S1_C1_2,     frontLeft,     tmotorTetrix, PIDControl, encoder)
#pragma config(Motor,  mtr_S1_C2_1,     rearLeft,      tmotorTetrix, PIDControl, encoder)
#pragma config(Motor,  mtr_S1_C2_2,     rearRight,     tmotorTetrix, PIDControl, reversed, encoder)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

#include <JoystickDriver.c>

int x1, y1, x2;

void initializeRobot()
{
}

task main()
{
	initializeRobot();
	float driveScale = (0.7874*0.78);
	int threshold = 8;

	while (1)
	{
		getJoystickSettings(joystick);
	x1 = (abs(joystick.joy1_x1) > threshold) ? joystick.joy1_x1 * driveScale : 0;
	y1 = (abs(joystick.joy1_y1) > threshold) ? joystick.joy1_y1 * driveScale : 0;
	x2 = (abs(joystick.joy1_x2) > threshold) ? joystick.joy1_x2 * driveScale : 0;

		motor [frontLeft] = y1 + x2 + x1;
		motor [frontRight] = y1 - x2 - x1;
		motor [rearLeft] = y1 + x2 - x1;
		motor [rearRight] = y1 - x2 + x1;

		//motor [frontLeft] = (abs(joystick.joy1_y1) > threshold) ? joystick.joy1_y1 * driveScale : 0;
		//motor [rearRight] = (abs(joystick.joy1_y1) > threshold) ? joystick.joy1_y1 * driveScale : 0;
		//motor [frontRight] = (abs(joystick.joy1_y2) > threshold) ? joystick.joy1_y2 * driveScale : 0;
		//motor [rearLeft] = (abs(joystick.joy1_y2) > threshold) ? joystick.joy1_y2 * driveScale : 0;
	}
}
